import {ajax} from "@/utils/ajax.js"
import {CODES} from "@/utils/vip.js"

const cache = new Map();


export const  getVipConfigs = async () =>{
	if(cache.has('getVipConfigs')){
		return cache.get('getVipConfigs')
	}
	const res = await ajax({
		url:'/vipOpenConfig/leveList',
		data:{}
	})
	cache.set('getVipConfigs',res)
	return res
}

export const getVipRules = async (levelCode) =>{
	const key = `getVipRules_${levelCode}`
	if(cache.has(key)){
		return cache.get(key)
	}
	const res = await ajax({
		url:'/vipGroupRuleRel/rule',
		data:{
			levelCode
		}
	})
	cache.set(key,res)
	return res
}
export const getVipPowers = async()=>{
	const key = `getVipPowers`
	if(cache.has(key)){
		return cache.get(key)
	}
	const res = await ajax({
		url:'/vipGroupRuleRel/groupRuleList',
		data:{}
	})
	cache.set(key,res)
	return res
}

